package com.instala.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Connectionmanager {
	private static Log log = LogFactory.getLog(Connectionmanager.class);

	public Connection getConectionaspel(){
		
		Connection connection =null;
		try {
			Class.forName("org.firebirdsql.jdbc.FBDriver");
			connection = DriverManager
					.getConnection(
							"jdbc:firebirdsql:127.0.0.1/3050:c:/aspel/DATOSINS.FDB",
							"SYSDBA", "masterkey");
			log.info("se genero la conexion correctamente aspel");
		}catch (SQLException e){
		log.error("Falla al intentar generar la conexion aspel \n"+e);
		} catch (ClassNotFoundException e) {
			log.error("Firebird JCA-JDBC driver not found in class path");
		}
		return connection;
	}
	public Connection getConectionPostgres(){
	
		Connection connection=null;
		
		try {
 
			Class.forName("org.postgresql.Driver");


			connection = DriverManager.getConnection(
					"jdbc:postgresql://127.0.0.1:5433/faltantesinstala", "clienteinstala",
					"aplicacionfaltante");
			if(log.isDebugEnabled())
			log.info("se genero la conexion correctamente postgres");
		}catch (SQLException e){
			log.error("Falla al intentar generar la conexion postgres \n"+e);
			} catch (ClassNotFoundException e) {
				log.error("Postgres JCA-JDBC driver not found in class path");
			}

		return connection;
		
	
	}
	
	public void cerrarConexion(Connection con)
	{
		try {
			if(con!=null)
			con.close();
		} catch (SQLException e) {
		log.error("error al cerrar la conexion");
		}
		
	}
}
